/**
 * 
 */
package sistema.submissao.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * @author Thiago Emmanuel Pereira da Cunha Silva, thiago.manel@gmail.com
 * @since 07/05/2006
 */
public class SubmissaoFileUtils {

	/**
	 * 
	 * @param stream
	 * @return
	 */
	public static String trataStream(InputStream stream){
		BufferedReader buffer = null;
		String line = null;
		StringBuffer output = new StringBuffer();
		
		try {
	        buffer = new BufferedReader(new InputStreamReader(stream));
	        while ((line = buffer.readLine()) != null) {
	            output.append(line + "\n");
	            
	        }
	    } catch (IOException ioe) {
	        System.err.println("[ERROR] "  + ioe.getMessage());
	    } finally {
	        if (buffer != null) {
	            try {
	                buffer.close();
	            } catch (IOException e) {
	
	            }
	        }
	    }
		return output.toString();
	}
}
